package com.lb.request;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class BrowserController {
    private WebDriver driver;

    public BrowserController() {
        System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--headless=new");
        options.addArguments("--disable-gpu");
        options.addArguments("--window-size=1,1"); // 设置窗口大小
        driver = new ChromeDriver(options);
    }

    public void navigateTo(String url) {
        driver.get(url);
    }

    public String getTitle() {
        return driver.getTitle();
    }

    public String getCookie() {
        return driver.manage().getCookies().toString();
    }

    public void close() {
        driver.quit();
    }
}